import { ColumnsType } from "@/components";
import { h } from "vue"
import { ElText } from "element-plus"

/**
 * Table 字段对应 Label
 */
export enum TableLabel {
    Id = "ID",
    ShopCode = "店铺编码",
    DishId = "菜式ID",
    DishName = "菜式名",
    DishCode = "菜式编码",
    Enable = "菜式是否上架",
    Price = "价格",
    CreatedAt = "创建时间",
    UpdatedAt = "更新时间",

}

export const columns: ColumnsType[] = [
    {
        minWidth: 100,
        label: TableLabel.Id,
        prop: "Id"
    },
    {
        minWidth: 120,
        label: TableLabel.ShopCode,
        prop: "ShopCode"
    },
    {
        minWidth: 120,
        label: TableLabel.DishId,
        prop: "DishId"
    },
    {
        minWidth: 120,
        label: TableLabel.DishName,
        prop: "DishName"
    },
    {
        minWidth: 120,
        label: TableLabel.DishCode,
        prop: "DishCode"
    },
    {
        width: 120,
        label: TableLabel.Enable,
        prop: "Enable",
        formatter(row, column, cellValue) {
            return h(ElText, {
                tag: "b",
                type: cellValue ? "success" : "danger",
            }, () => cellValue ? "上架" : "下架");
        },
    },
    {
        minWidth: 120,
        label: TableLabel.Price,
        prop: "Price"
    },
    {
        width: 180,
        DateFormat: true,
        sortable: true,
        label: TableLabel.CreatedAt,
        prop: "CreatedAt"
    },
    {
        width: 180,
        DateFormat: true,
        sortable: true,
        label: TableLabel.UpdatedAt,
        prop: "UpdatedAt"
    },
]